home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
Xprof
/
xprof
/
reply.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
117 lines
/*==================================================================
* File : reply.c
* Package: Xprof
*
* Author : Aloke Gupta.
*
* (C) Copyright 1992, Aloke Gupta.
*==================================================================*/
/*
* Processing routines for the replies seen in the message stream.
* Functions:
* 1. process_reply(FILE *fp, char *string, GlobalStats *gstats)
* 2. print_reply_stats(FILE *fp)
* 3. The routines to process each reply seen. These have the format:
* Reply(FILE *fp, reply_index, current_time)
*/
#include <stdio.h>
#include "common.h"
MsgStats TotalReplyStats; /* Overall stats for all replies */
MsgStats ReplyStats[MAXREPLIES]; /* Detailed stats for each reply */
/*static char in_string[MAXSTRINGSIZE];*/ /* Buffer to read a record into */
static char sbuf[132]; /* Temp. slots for sscanf*/
extern MsgType ReplyType[];
extern int lookup_reply(); /* Get index of this request */
process_reply(fp, string, gstats)
FILE *fp; /* Pointer to input stream */
char *string;
GlobalStats *gstats;
{
char reply_name[80]; /* Name of the current reply */
int reply_index; /* Index in the data structures */
long bytes=0; /* Number of bytes */
if (TotalReplyStats.invoked == FALSE)
InitMsgStats(&TotalReplyStats, gstats->current_time, DETAILED, GRAIN1);
sscanf(string, "%s %s",sbuf, reply_name);
reply_index = lookup_reply(reply_name);
/* Call the action for this reply */
bytes = ReplyType[reply_index].action(fp,reply_index,gstats->current_time);
/*
* Fill the data structure for all the replies. The size distribution
* is maintained for the total number of bytes received.
*/
FillMsgStats(&TotalReplyStats, gstats->current_time, bytes, bytes);
gstats->reply_bytes += bytes;
}
print_reply_stats(fp)
FILE *fp;
{
int i;
static char *dashes = {
"---------------------------------------------------------------"};
if (TotalReplyStats.invoked == FALSE)
return;
/*
* Print the details for all Replies together
*/
PrintMsgStats(fp,&TotalReplyStats, "REPLIES ");
/*
* Brief table for the numbers and byte totals for the replies
*/
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"\n%-25s", " REPLY messages");
fprintf(fp,"%25s", "Total Bytes ");
fprintf(fp," %19s\n","Number ");
fprintf(fp,"\t%s\n", dashes);
for (i = 0; i < MAXREPLIES; i++)
if (ReplyStats[i].invoked == TRUE) {
fprintf(fp,"%-25s", ReplyType[i].name);
fprintf(fp," %10ld bytes",ReplyStats[i].total_bytes);
fprintf(fp," (%5.2f%%)", (float) 100 * ReplyStats[i].total_bytes /
TotalReplyStats.total_bytes);
fprintf(fp," %10ld", ReplyStats[i].number );
fprintf(fp," (%5.2f%%)", (float) 100 * ReplyStats[i].number /
TotalReplyStats.number);
fprintf(fp,"\n");
}
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"%25s"," Grand Total ");
fprintf(fp," %10ld bytes ", TotalReplyStats.total_bytes);
fprintf(fp," %10ld \n", TotalReplyStats.number);
fprintf(fp,"\t%s\n", dashes);
if (verboselevel > 0) {
for (i = 0; i < MAXREPLIES; i++)
if (ReplyStats[i].detailed == DETAILED)
PrintMsgStats(fp,&ReplyStats[i], ReplyType[i].name);
}
/*
* Now dump the raw statistics for the messages
*/
if (verboselevel > 1) {
if (TotalReplyStats.detailed == DETAILED)
PrintMsgDetails(fp,&TotalReplyStats, "REPLIES ");
for (i = 0; i < MAXREPLIES; i++)
if (ReplyStats[i].detailed == DETAILED)
PrintMsgDetails(fp,&ReplyStats[i], ReplyType[i].name);
}
return;
}